<?php

// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------


namespace app\common\repositories\system\notice;


use app\common\dao\system\notice\SystemAppNoticeConfigDao;
use app\common\repositories\BaseRepository;
use crmeb\exceptions\WechatException;
use crmeb\services\MiniProgramService;
use crmeb\services\WechatService;
use FormBuilder\Factory\Elm;
use think\exception\ValidateException;
use think\facade\Route;

/**
 * Class SystemAppNoticeConfigRepository
 * @package app\common\repositories\system\notice
 * @mixin SystemAppNoticeConfigDao
 */
class SystemAppNoticeConfigRepository extends BaseRepository
{
    public function __construct(SystemAppNoticeConfigDao $dao)
    {
        $this->dao = $dao;
    }


    public function getList(array $where, $page, $limit)
    {
        $query = $this->dao->getSearch($where);
        $count = $query->count();
        $list = $query->page($page, $limit)->order('create_time ASC')->select();
        return compact('count', 'list');
    }


    public function swithStatus($id, $status)
    {
        $data = $this->dao->get($id);
        $data->notice_status = $status;
        $data->save();
    }

    public function detail($id)
    {
        $data = $this->dao->get($id);
        if(!$data) return [];
        return $data;
    }


}
